import request from '@/utils/request'
import { encryptedData } from '@/utils/encrypt'
import { loginRSA, tokenName } from '@/config'

export function login(data) {
  // if (loginRSA) {
  //   data = await encryptedData(data)
  // }
  return request({
    url: '/user/login',
    method: 'post',
    data,
  })
}

export function getUserInfo() {
  return request({
    url: '/user/getUserInfo',
    method: 'get',
  })
}

export function logout() {
  return request({
    url: '/user/loginOut',
    method: 'get',
  })
}
export function register() {
  return request({
    url: '',
    method: 'post',
  })
}
export function Register(data) {
  return request({
    url: '/user/registerUser',
    method: 'post',
    data,
  })
}
export function getUserList(data) {
  return request({
    url: '/user/getUserInfoList',
    method: 'post',
    data,
  })
}
export function updateUserInfo(data) {
  return request({
    url: '/user/updateUserInfo',
    method: 'post',
    data,
  })
}

// /userEstateMap/getByQuery
// 获取绑定的地产信息
// estateId (string, optional): 房产id 或者 楼板id ,
// estateType (integer, optional): 1-房产信息 2-楼盘信息 ,
// roleId (string, optional): 用户角色 2-户主 3-开发商 4-驻场人员 ,
// userId (string, optional): 驻场人员id
export function getByQuery(data) {
  return request({
    url: '/userEstateMap/getByQuery',
    method: 'post',
    data,
  })
}
//驻场人员新增地产或房产信息
// estateId (string, optional): 房产id 或者 楼板id ,
// estateType (integer, optional): 1-房产信息 2-楼盘信息 ,
// roleId (string, optional): 用户角色 2-户主 3-开发商 4-驻场人员 ,
// userId (string, optional): 驻场人员id
export function addUserBusinessEstate(data) {
  return request({
    url: '/userEstateMap/addUserBusinessEstate',
    method: 'post',
    data,
  })
}

//
export function getDevelopList(data) {
  return request({
    url: '/developer/getPreviewList',
    method: 'post',
    data,
  })
}

export function updateStatus(data) {
  return request({
    url: '/developer/updateStatus',
    method: 'post',
    data,
  })
}

export function deleteUser(data) {
  return request({
    url: '/user/deleteUserInfo',
    method: 'post',
    data,
  })
}

export function deleteDeveloperInfo(data) {
  return request({
    url: '/developer/deleteDeveloperInfo',
    method: 'post',
    data,
  })
}
// /developer/getDeveloperCompanyInfo
export function showDeveloperInfo(id) {
  return request({
    url: '/developer/getDeveloperCompanyInfo',
    method: 'get',
    params: { userId: id },
  })
}

export function getCodeByPhone(p) {
  return request({
    url: '/phoneCode',
    method: 'get',
    params: { phone: p },
  })
}
//

export function updateUserPasswordByPhoneCode(data) {
  return request({
    url: '/user/updateUserPasswordByPhoneCode',
    method: 'post',
    data,
  })
}
